e550d5
@@ -456,26 +456,29 @@
public class XsltBuilder implements Processor {
             return new StreamSource((InputStream)body);
         }
         if (body != null) {
-            TypeConverter tc = exchange.getContext().getTypeConverterRegistry().lookup(Source.class, body.getClass());
-            if (tc != null) {
-                source = tc.convertTo(Source.class, exchange, body);
+            if (isAllowStAX()) {
+                source = exchange.getContext().getTypeConverter().tryConvertTo(StAXSource.class, exchange, body);
+            }
+            if (source == null) {
+                // then try SAX
+                source = exchange.getContext().getTypeConverter().tryConvertTo(SAXSource.class, exchange, body);
+            }
+            if (source == null) {
+                // then try stream
+                source = exchange.getContext().getTypeConverter().tryConvertTo(StreamSource.class, exchange, body);
+            }
+            if (source == null) {
+                // and fallback to DOM
+                source = exchange.getContext().getTypeConverter().tryConvertTo(DOMSource.class, exchange, body);
+            }
+            // as the TypeConverterRegistry will look up source the converter differently if the type converter is loaded different
+            // now we just put the call of source converter at last
+            if (source == null) {
+                TypeConverter tc = exchange.getContext().getTypeConverterRegistry().lookup(Source.class, body.getClass());
+                if (tc != null) {
+                    source = tc.convertTo(Source.class, exchange, body);
+                }
             }
-        }
-
-        if (source == null && isAllowStAX()) {
-            source = exchange.getContext().getTypeConverter().tryConvertTo(StAXSource.class, exchange, body);
-        }
-        if (source == null) {
-            // then try SAX
-            source = exchange.getContext().getTypeConverter().tryConvertTo(SAXSource.class, exchange, body);
-        }
-        if (source == null) {
-            // then try stream
-            source = exchange.getContext().getTypeConverter().tryConvertTo(StreamSource.class, exchange, body);
-        }
-        if (source == null) {
-            // and fallback to DOM
-            source = exchange.getContext().getTypeConverter().tryConvertTo(DOMSource.class, exchange, body);
         }
         if (source == null) {
             if (isFailOnNullBody()) {
